<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        str = " Hello World! "

        let str_charAt = str.charAt(1) //通过字符串的下标找到目标值
        console.log(str_charAt)

        let str_charCodeAt = str.charCodeAt(0) //获取该索引对应字符的ASCLL码
        console.log(str_charCodeAt)

        let ascll = String.fromCharCode(65) //获取该ASCLL码对应的字符
        console.log(ascll)

        let str_indexOf = str.indexOf("W") //从前向后在目标字符串中寻找该字符，并返回第一次出现时对应的索引
        console.log(str_indexOf)

        let str_lastIndexOf = str.lastIndexOf("H") //从后向前在目标字符串中寻找该字符，并返回第一次出现时对应的索引
        console.log(str_lastIndexOf)

        let str_slice = str.slice(1, 6) //截取字符串，[开始位置下标， 结束位置)
        console.log(str_slice)

        let str_split = str.split(" ") //字符串转化为数组，传参为以...为基准分割
        console.log(str_split)

        let str_replace = str.replace("World", "JaveScript") //用第二个值替换第一个值
        console.log(str_replace)

        let str_trim = str.trim() //去掉两端的空格
        console.log(str_trim)

        let str_toUpperCase = str.toUpperCase() //转大写
        console.log(str_toUpperCase)

        let str_toLowerCase = str.toLowerCase() //转小写
        console.log(str_toLowerCase)

        let str_substr = str.substr(1, 5) //截取字符串，值1为起点，值2为长度
        console.log(str_substr)
        
        let str_substring = str.substring(1, 6) //截取字符串，[开始位置下标， 结束位置)
        console.log(str_substring)

        let str_startsWith = str.startsWith("d") //判断首个字符是否与传入参数相同
        console.log(str_startsWith)

        let str_endsWith = str.endsWith("d") //判断末位字符是否与传入参数相同
        console.log(str_endsWith)

        let str_includes = str.includes("d") //判断字符串内是否包含该字符
        console.log(str_includes)
    </script>
</body>
</html>